#include("../../comm/ListHead.html")
<div class="layui-fluid layui-anim layui-anim-scale">
    <div class="layui-row layui-col-space5">
        <div class="layui-col-md12 height-auto">
            <div class="layui-card">
                <div class="card-search SearchTable">
                    <div style="float:right">
                        <div class="layui-inline layui-input-wrap">
                            <span class="layui-input-prefix"><i class="layui-icon layui-icon-file"></i></span>
                            <input type="text" id="file_name" lay-verify="required" placeholder="文件名" autocomplete="off"
                                   class="table-search-text width120">
                        </div>
                        <input type="text" id="filepath" lay-verify="required" placeholder="路经" autocomplete="off"
                               class="table-search-text width220">
                        <button class="layui-btn layui-btn-warm layui-btn-sm" lay-event="DoSearch">
                            搜索
                        </button>
                        <button class="layui-btn layui-hide" id="uploadbtn">上传文件</button>
                    </div>
                    <i class="layui-icon layui-icon-slider"></i>
                    当前位置 > <span class="color_green">上传文件列表</span>
                </div>
                <div class="layui-card-body">
                    <table class="layui-hide" id="table_1" lay-filter="table_1"></table>

                    <script type="text/html" id="table_1_bar_title">
                        <div class="layui-btn-container left">
                            <button class="layui-btn layui-btn-sm btn-add" lay-event="AddSysFile">
                                <i class="layui-icon">&#xe608;</i> 上传新文件
                            </button>
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-one="btn-edit" lay-event="EditSysFile">修改</button>
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-one="btn-del" lay-event="DelSysFile">删除</button>
                        </div>
                        <div id="bar"></div>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<script language="JavaScript">

    layui.use(['myTable', 'table', 'form', 'util', 'myTool', 'upload'], function () {
        var $ = layui.$;
        myTable = layui.myTable, table = layui.table
        form = layui.form, util = layui.util, myTool = layui.myTool;

        layui.upload.render({
            elem: '#uploadbtn', url: 'UploadImages', size: 30000, accept: 'file', exts: ''
            , done: function (res) {
                if (res.code == 0) {
                    tableindex.reload();
                    layer.msg('上传成功');
                } else {
                    layer.msg('上传失败');
                }
            }
        });
        tableindex = myTable.render({
            url: 'SysFileListDataApi'
            , title: '文件上传列表'
            , cols: [[
                {type: 'checkbox', width: 36, fixed: true}
                , {field: 'file_id', title: '编号', width: 50, align: 'center'}
                , {field: 'file_type_html', title: '类型', width: 76, align: 'center'}
                , {field: 'file_name', title: '文件名', width: 150}
                , {field: 'file_ext', title: '扩展名', width: 80}
                , {field: 'file_path', title: '路经', width: 260}
                , {field: 'file_size_html', title: '大小', width: 80}
                , {field: 'save_month', title: '上传年月', width: 86, align: 'center'}
                , {field: 'create_time', title: '上传时间', width: 170}
                , {field: 'update_username', title: '上传人', width: 80}
                , {field: 'file_desc', title: '备注'}
            ]]
            , page: true, limit: 10
            , editField: {url: 'ModifySysFileFieldApi', key: 'file_id'}
        });

        util.event("lay-event", {
            DoSearch: function () {
                tableindex.reload({
                    where: {
                        like: {file_name: $("#file_name").val(), file_path: $("#filepath").val()}
                    }
                    , page: {curr: 1}
                });
            }
        });

        //头工具栏事件
        table.on('toolbar(table_1)', function (obj) {
            myTool.toolbar(this, obj, {
                AddSysFile: function () {
                    $("#uploadbtn").click();
                }
                , EditSysFile: function () {
                    myTool.doSingleSelect(myTable.checkStatus('table_1'), {}, function (data, keys) {
                        index = top.layer.open({
                            type: 2, offset: '50px', area: ['800px', '550px'], title: ['修改文件[' + data[0].file_name + ']', 'font-size:15px;'],
                            content: ["sysfile/EditSysFile?file_id=" + data[0].file_id, 'no'],
                            end: function () {
                                tableindex.reload({});
                            }
                        });
                    });
                }
                , DelSysFile: function () {
                    myTool.doSingleSelect(myTable.checkStatus('table_1'), {}, function (data, keys) {
                        index = top.layer.confirm('你是否确认删除【' + data[0].file_name + '】', {icon: 3, title: '提示', offset: '100px'}, function (index2) {
                            top.layer.close(index2);
                            myTool.postMsg("DelSysFileApi", {file_id: data[0].file_id}, function () {
                                tableindex.reload();
                            });
                        });
                    });
                }
            });
        });

        //监听锁定操作
        form.on('checkbox(LockCom)', function (obj) {
            myTool.postMsg("LockSysFileApi", {hall_id: this.value}, function (result) {
                layer.tips(result.msg, obj.othis);
            });
        });
    });
</script>
#include("../../comm/Foot.html")